<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" type="text/css" href="css/cate_news.css">
    <script type="text/javascript" src="./js/jquery-1.8.2.min.js" ></script>


	<script src="https://unpkg.com/vue"></script>
    <script src="http://cdn.bootcss.com/vue/2.1.0/vue.js" type="text/javascript" charset="utf-8"></script>
    <script src="http://cdn.bootcss.com/vue-resource/1.0.3/vue-resource.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
	<script>
        $(function(){
         $("#public").load("./public.html");
    });
    </script>
	<div id="public"></div>
	<div id="index_body">
	    <div id="left">
	    	<h2>欢迎您来到1802PHP的新闻首页</h2>
	    	<ul>
	    		<li>生活不止眼前的苟且</li>
	    		<li>还有诗和远方的田野</li>
		    </ul>
	    	<div id="cate_news_content" v-for="(val,key) in cate_news_content.ncate">
		    	<dl>
		    		<dt v-if="val.img_url==null"><img src="./images/1.jpg" width="80px;" height="80px;"></dt>
		    		<dt v-else-if="val.img_url!=null"><img v-bind:src="['http://'+val.img_url]" width="80px;" height="80px;"></dt>
		    		<p><a v-bind:href="['./content.html?news_id='+val.news_id]">{{val.news_title}}</a></p>
		    		<p class="content"><a v-bind:href="['./content.html?news_id='+val.news_id]">{{val.news_desc}}</a></p>
		    	</dl>
		    </div>
	    </div>
	    <div id="right" v-for="(val,key) in cate_news_content.ads">
		    <img v-bind:src="['http://'+val.ad_img]" alt="">
	    </div>
    </div>



	 <script>
	   
	    //获取地址栏的id
	    function getQueryString(name) {
	        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
	        var r = window.location.search.substr(1).match(reg);
	        if (r != null)
	            return unescape(r[2]);
	            return null;
	    }

	    //调用函数获取id 并声明为全局变量
	    var cate_id = getQueryString("cate_id");

	    var cate_news='';
	    
	    $.ajax({
	        url:'http://10.101.147.56/try/news_news/tp5.0/public/adNews',
	        type:'post',
	        async:false,
	        data:{
	            cate_id:cate_id
	        },
	        success:function(data){

	        	cate_news = data; 

	            // if(data.status==1){
	            //     // cate_news = data; 
	            //      console.log(data)
	            // }
	            // else{
	            //     alert(1);
	            // }
	             //console.log(data)
	        }
	    });

	    new Vue({
	        el:'#index_body',
	        data:{
	            cate_news_content:cate_news
	        }
	    });

	    // console.log(cate_news);
	  
	</script>
</body>
</html>